package bakaLevel;

import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;

public class PlayerPVEHandler {
	public static void handle(EntityDamageByEntityEvent event) {
		Monster victim = (Monster) event.getEntity();
		Player damager = (Player) event.getDamager();
		//get instance of player datas
		PlayerLevelReader r = BAKALevel.instance.GetPlayerInstance(damager.getName());
		
		//convert monster name
		String strMonsterName = victim.getCustomName();
		if(strMonsterName == null) strMonsterName = victim.getName();
		
		if(event.getFinalDamage() > victim.getHealth())
		{
			//get how many exp should player gain.
			int intExp = BAKALevel.instance.MonsterExpList.get(strMonsterName);
			r.playerGainExp(intExp);
			r.AddKillCount();
		}
		r.AddDamageToMonster((int) event.getFinalDamage());
	}
	
	
}
